﻿
@{
    ViewBag.Title = "AddRole";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}

<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-admin-role-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>角色名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="Role_Name" name="Role_Name">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">备注：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea class="input-text" style="height:300px;" value="" placeholder="" id="Description" name="Description"></textarea>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-success radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
            </div>
        </div>
    </form>
</article>
@section script{
    <script type="text/javascript" src="~/Content/H-ui.admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
    <script type="text/javascript" src="~/Content/H-ui.admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
    <script type="text/javascript" src="~/Content/H-ui.admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
    <script type="text/javascript">
        $(function () {
            
            $("#form-admin-role-add").validate({
                rules: {
                    Role_Name: {
                        required: true,
                    },
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",
                submitHandler: function (form) {
                    var Role_Name = $("#Role_Name").val();
                    var Description = $("#Description").val();
                    $.post("/admin/power/addrole", { Role_Name: Role_Name, Description: Description }, function (data) {
                        console.log(data);
                        if (data.code == 0) {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        } else {
                            alert(data.msg);
                        }
                    })
                }
            });
        });
    </script>

}